package com.auxgroup.smarthome.entity;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.auxgroup.smarthome.bean.Attr;
import com.auxgroup.smarthome.bean.SleepDiyAttr;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * 设备睡眠表DIY实体类
 * Created by niuGuangzhe on 2017/7/26.
 */
public class AppSleepDiyEntity extends AbstractGenericEntity {

    private String sleepDiyId;

    private String deviceId;

    private String name;

    private Integer mode;

    private Integer definiteTime;

    private Integer startHour;

    private Integer startMinute;

    private Integer endHour;

    private Integer endMinute;

    private Integer windSpeed;

    private Boolean smart;

    private String electricControl;

    private Integer deviceManufacturer;

    private Boolean on;

    private Boolean enable;

    public String getSleepDiyId() {
        return sleepDiyId;
    }

    public void setSleepDiyId(String sleepDiyId) {
        this.sleepDiyId = sleepDiyId;
    }

    public String getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getMode() {
        return mode;
    }

    public void setMode(Integer mode) {
        this.mode = mode;
    }

    public Integer getStartHour() {
        return startHour;
    }

    public void setStartHour(Integer startHour) {
        this.startHour = startHour;
    }

    public Integer getStartMinute() {
        return startMinute;
    }

    public void setStartMinute(Integer startMinute) {
        this.startMinute = startMinute;
    }

    public Integer getEndHour() {
        return endHour;
    }

    public void setEndHour(Integer endHour) {
        this.endHour = endHour;
    }

    public Integer getEndMinute() {
        return endMinute;
    }

    public void setEndMinute(Integer endMinute) {
        this.endMinute = endMinute;
    }

    public Integer getWindSpeed() {
        return windSpeed;
    }

    public void setWindSpeed(Integer windSpeed) {
        this.windSpeed = windSpeed;
    }

    public Boolean getSmart() {
        return smart;
    }

    public void setSmart(Boolean smart) {
        this.smart = smart;
    }

    public Boolean getOn() {
        return on;
    }

    public void setOn(Boolean on) {
        this.on = on;
    }

    public Boolean getEnable() {
        return enable;
    }

    public void setEnable(Boolean enable) {
        this.enable = enable;
    }

    public String getElectricControl() {
        return electricControl;
    }

    public void setElectricControl(String electricControl) {
        this.electricControl = electricControl;
    }

    public Integer getDefiniteTime() {
        return definiteTime;
    }

    public void setDefiniteTime(Integer definiteTime) {
        this.definiteTime = definiteTime;
    }

    public Integer getDeviceManufacturer() {
        return deviceManufacturer;
    }

    public void setDeviceManufacturer(Integer deviceManufacturer) {
        this.deviceManufacturer = deviceManufacturer;
    }

    /**
     * 是否到时间点
     * @return
     */
    public boolean atTime(){
        int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
        return hour >= startHour && hour <= endHour;
    }

    /**
     * 解析电控指令列表
     * @return
     */
    public List<SleepDiyAttr> resolveElectricControl(){
        return JSON.parseArray(this.electricControl,SleepDiyAttr.class);
    }

}
